#include <scene/scene.h>

ceScene::ceScene()
  : iObject ()
{
  CE_OBJECT_CONSTR
}

void ceScene::AddSector(ceSector *sector)
{
  if (sector) sector->AddRef();
  _sectors.push_back (sector);
}

void ceScene::RemoveSector(ceSector *sector)
{
  std::list<ceSector*>::iterator it;
  for (it = _sectors.begin (); it != _sectors.end (); ++it)
    {
      ceSector* s = *it;
      if (s == sector)
        {
          _sectors.erase (it);
          s->Release();
          return;
        }
    }
}

ceSectorList& ceScene::GetSectors()
{
  return _sectors;
}

const ceSectorList& ceScene::GetSectors() const
{
  return _sectors;
}

void ceScene::FindSectorLights (bool clearLights)
{
  std::list<ceSector*>::iterator it;
  for (it = _sectors.begin (); it != _sectors.end (); ++it)
    {
      ceSector* s = *it;
			s->FindSectorLights (clearLights);
		}
}


void ceScene::ApplyLights ()
{
  std::list<ceSector*>::iterator it;
  for (it = _sectors.begin (); it != _sectors.end (); ++it)
    {
      ceSector* s = *it;
			s->ApplyLights ();
		}
}
